package com.future.bantang.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.future.bantang.entity.GoodThingsCategorysEntity;
import com.future.bantang.fragment.FragmentGoodthings;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by zzh on 2016/1/12.
 * 适用于tbs和viewPager组成的分页导航
 */
public class TbsFraViewPagerAdapter extends FragmentPagerAdapter {
    public static final String TAG = "TbsFraViewPagerAdapter";
    //栏目分类信息
    List<GoodThingsCategorysEntity.DataEntity> lst = new ArrayList<>();

    public TbsFraViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    //外界放入分类数据
    public void setCategorys(List<GoodThingsCategorysEntity.DataEntity> lst) {
        this.lst = lst;
    }

    @Override
    public Fragment getItem(int position) {
        //根据分类id返回对应fragment
        return FragmentGoodthings.newInstance(lst.get(position).getId());
    }

    @Override
    public int getCount() {
        return lst.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return lst.get(position).getName();
    }
}
